package com.zhao.sparkstreaming.index_project

import java.sql.Connection
import java.util.Properties

import com.alibaba.druid.pool.DruidDataSourceFactory
import javax.sql.DataSource

/**
 * Description: <br/>
 * Copyright (c) ，2020 ， 赵 <br/>
 * This program is protected by copyright laws. <br/>
 * Date： 2020/9/20 15:00
 *
 * @author 柒柒
 * @version : 1.0
 */

object DruidConnectionPool {
  private val props = new Properties()
  props.put("driverClassName", "com.mysql.jdbc.Driver")
  props.put("url", "jdbc:mysql://node01:3306/test?characterEncoding=UTF-8")
  props.put("username", "root")
  props.put("password", "123456")
  private val source: DataSource = DruidDataSourceFactory.createDataSource(props)
  def getConnection: Connection = {
    source.getConnection
  }
}
